import unittest
from qinjiwei.jichufunction.buildnewshiwu import newshiwu
from qinjiwei.jichufunction.login import login
class OaDaiBanShiWu(unittest.TestCase):
    '''正向测试待办事物'''
    def setUp(self) -> None:
        self.driver = login()
        self.driver.maximize_window()
        self.driver.implicitly_wait(5)
        newshiwu(self.driver)
    def test01(self):
        '''正向测试处理的待办事物'''
        #定位待办事物元素并点击
        self.driver.find_element('link text','待办事项').click()
        #切换到第一层frame
        self.driver.switch_to.frame(self.driver.find_element('id','iframe_main'))
        #切换到第二层frame
        self.driver.switch_to.frame(self.driver.find_element('xpath','/html/frameset/frame[1]'))
        #定位待办事物按钮并点击
        self.driver.find_element('xpath','/html/body/form[1]/div[2]/div/div[1]/div[2]/table/tbody/tr[1]/td[3]/div/a').click()
        #返回到最外层
        self.driver.switch_to.default_content()
        #切换到第一层frame
        self.driver.switch_to.frame(self.driver.find_element('xpath','/html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td/div/iframe'))
        #定位处理按钮
        self.driver.find_element('xpath','/html/body/div[2]/button[3]').click()
        #返回到最外层
        self.driver.switch_to.default_content()
        #切换到第一层frame
        self.driver.switch_to.frame(self.driver.find_element('xpath',
                                                      '/html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td/div/iframe'))
        #定位处理意见
        self.driver.find_element('id','opinion').send_keys('通过')
        #定位确认提交按钮并点击
        self.driver.find_element('id','button_submit').click()

    def tearDown(self):
        self.driver.quit()

if __name__ == '__main__':
    unittest.main()